module.exports = function(sequelize, DataTypes) {
    var Product = sequelize.define('Product', {
        _id: {
            type: DataTypes.INTEGER(11),
            allowNull: false,
            primaryKey: true,
            autoIncrement: true
        },
        name: {
            type: DataTypes.TEXT,
            allowNull: false,
            field: "name",
            comment: "产品名称"
        },
        thumbnail: {
            type: DataTypes.TEXT,
            allowNull: false,
            field: "thumbnail",
            comment: "产品缩略图"
        },
        conditionLive: {
            type: DataTypes.TEXT,
            field: "conditionLive",
            comment: "产品使用场合(居住)"
        },
        conditionWork: {
            type: DataTypes.TEXT,
            field: "conditionWork",
            comment: "产品使用场合(办公)"
        },
        conditionShop: {
            type: DataTypes.TEXT,
            field: "conditionShop",
            comment: "产品使用场合(经营)"
        },
        poster: {
            type: DataTypes.TEXT,
            allowNull: false,
            field: "poster",
            comment: "产品banner图"
        },
        desc: {
            type: DataTypes.TEXT,
            allowNull: false,
            field: "desc",
            comment: "产品用途描述"
        },
        detail: {
            type: DataTypes.TEXT,
            allowNull: false,
            field: "detail",
            comment: "产品参数描述"
        },
        bonus: {
            type: DataTypes.INTEGER,
            allowNull: false,
            field: 'bonus',
            comment: '产品安全评分'
        }
    }, {
        timestamps: false,
        tableName: 'device',
        classMethods: {
            associate: function (models) {
                Product.belongsTo(models.Category, {foreignKey: 'categoryId', targetKey: '_id'});
            }
        }
    });
    return Product;
}